#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //
    btnClose=new QPushButton(this);
    btnClose->setText("关闭");
    connect(btnClose,SIGNAL(clicked()),this,SLOT(close()));


}
//获取鼠标点定位窗体位置
void MainWindow::mousePressEvent(QMouseEvent *e)
{
  last=e->globalPos();
}
void MainWindow::mouseMoveEvent(QMouseEvent * e)
{
 int dx=e->globalX()-last.x();
 int dy=e->globalX()-last.y();
 last=e->globalPos();
 move(x()+dx,y()+dy);
}
void MainWindow::mouseReleaseEvent(QMouseEvent *e)
{
    int dx=e->globalX()-last.x();
    int dy=e->globalY()-last.y();
    move(x()+dx,y()+dy);
}
MainWindow::~MainWindow()
{
    delete ui;
}
